//
//  RecordingDetailView.swift
//  APIEndPoint
//
//  Created by Alfred on 2021/2/7.
//

import SwiftUI

struct RecordingDetailView: View {
   
    
    private var timeStamp: String
    private var jsonData: Data?
    private var userModel: UserModel?
    

    
    init(timeStamp: String, jsonData: Data?) {
        self.timeStamp = timeStamp
        guard let jd = jsonData else {  return }
        self.jsonData = jsonData
        do {
            try userModel = JSONDecoder().decode(UserModel.self, from: jd)
        } catch let err {
            print(err.localizedDescription)
        }
    }
    
    var body: some View {
        List {
            CellView(userModel: self.userModel)
        }
            .navigationBarTitle(Text(timeStamp), displayMode: .automatic)
    }
}

struct RecordingDetailView_Previews: PreviewProvider {
    static var previews: some View {
        RecordingDetailView(timeStamp: "timeStamp", jsonData: nil)
    }
}
